package com.ui
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	
	import starling.display.Image;
	import starling.textures.Texture;
	import starling.textures.TextureAtlas;

	public class CustomSkin
	{
		[Embed(source="assets/customSkin.png")]
		private static var skinClass:Class;
		
		[Embed(source="assets/customSkin.xml",mimeType="application/octet-stream")]
		private static var skinXmlClass:Class;
		
		[Embed(source="assets/ColorSets.png")]
		public static var colorSetsClass:Class;
		
		public static var colorSetsBd:BitmapData = (new colorSetsClass() as Bitmap).bitmapData;
		
		private static var bitmap:Bitmap = new skinClass();
		private static var texture:Texture = starling.textures.Texture.fromBitmap(bitmap);
		private static var xml:XML = XML(new skinXmlClass());
		private static var sTextureAtlas:TextureAtlas = new TextureAtlas(texture,xml);
		private static var _texture:Texture;
		/**
		 *通过名字获取对应的材质 
		 * @param name 材质名
		 * @return 返回的材质
		 */		
		public static function getSkinTexture(name:String):Texture
		{
			return sTextureAtlas.getTexture(name);
		}
		/**
		 *通过传入的名字创建一个Image对象
		 * @param name 材质名
		 * @return 返回的Image
		 */	
		public static function getImage(name:String):Image
		{
			return new Image(getSkinTexture(name));
		}
		/**
		 *通过宽高、坐标、颜色创建一个Image对象
		 */	
		public static function introduce(w:Number,h:Number,_x:Number,_y:Number,c:Number):Image
		{
			var btm:BitmapData = new BitmapData(1,1,false,c);
			_texture = Texture.fromBitmapData(btm);
			var image:Image = new Image(_texture);
			image.width = w;
			image.height = h;
			image.x = _x;
			image.y = _y;
			return image;
		}
		
		public function CustomSkin()
		{
		}
		
		
	}
}